//package com.huc.tools.mq.consumer;
//
//import com.rabbitmq.client.Channel;
//import com.rabbitmq.client.QueueingConsumer;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import java.io.IOException;
//import java.util.concurrent.ExecutorService;
//import java.util.concurrent.Executors;
//
///**
// * @Author: 胡成
// * @Version: 0.0.1V
// * @Date: 2018/8/13
// * @Description: 类描述
// **/
//@Component
//public class RabbitmqStart {
//
////    @Autowired
////    private QueueingConsumer queueingConsumer;
//
//    @Autowired
//    private Channel channel;
//
//    public void start() throws InterruptedException, IOException {
//        ExecutorService service = Executors.newFixedThreadPool(3);
//        service.execute(()->{
//            try{
//                System.out.println("mq消费开始......");
//                /* 创建消费者对象，用于读取消息 */
//                QueueingConsumer consumer = new QueueingConsumer(channel);
//                channel.basicConsume("hello2", true, consumer);
//                /* 读取队列，并且阻塞，即在读到消息之前在这里阻塞，直到等到消息，完成消息的阅读后，继续阻塞循环 */
//                while (true) {
//                    QueueingConsumer.Delivery delivery = consumer.nextDelivery();
//                    String message = new String(delivery.getBody());
//                    System.out.println("收到消息'" + message + "'");
//                }
//            }catch (Exception e){
//                e.printStackTrace();
//            }
//        });
//    }
//}
